package com.hospital.config;

import com.hospital.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class MVCconfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //登录认证拦截器
        registry.addInterceptor(new LoginInterceptor())
                .excludePathPatterns(   //放行
//                        "/swagger-ui/index.html",
                        "/login",
                        "/register",
                        "/user/login",
                        "/user/signup",
                        "/doctor/signup",
                        "/patient/signup",
                        "/test/**"

                ).order(1);//指定拦截器执行顺序（从小到大）
    }

    public void addResourceHandlers(
            ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/js/**")
                .addResourceLocations("classpath:/static/js/");
        registry.addResourceHandler("/css/**")
                .addResourceLocations("classpath:/static/css/");
    }
}
